<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./code/chapter/19_paint.js"></script>
</head>

<body>
    <div></div>
    <script>
        // Change this method
        PictureCanvas.prototype.syncState = function (picture) {
            if (this.picture == picture) return;
            this.picture = picture;
            drawPicture(this.picture, this.dom, scale);
        };

        // You may want to use or change this as well
        function drawPicture(picture, canvas, scale) {
            canvas.width = picture.width * scale;
            canvas.height = picture.height * scale;
            let cx = canvas.getContext("2d");

            for (let y = 0; y < picture.height; y++) {
                for (let x = 0; x < picture.width; x++) {
                    cx.fillStyle = picture.pixel(x, y);
                    cx.fillRect(x * scale, y * scale, scale, scale);
                }
            }
        }

        document.querySelector("div")
            .appendChild(startPixelEditor({}));
    </script>
</body>

</html>